package cn.dmrliu.edu.publish.bean;

import cn.dmrliu.edu.publish.util.DoubleUtil;
import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor
public class ToolExamQuestionStats {
    String questionId;
    Long currentCt;
    Long answerCt;
    Long currentUvCt;
    Long answerUvCt;


    public Double getCorrectRate() {
        return DoubleUtil.toTwo((double) currentCt / (double) answerCt);
    }

    public Double getCorrectUvRate() {
        return DoubleUtil.toTwo((double) currentUvCt / (double) answerUvCt);
    }

    @Override
    public String toString() {
        return "{\n" +
                "  \"questionId\": \"" + this.questionId + "\",\n" +
                "  \"currentCt\": \"" + this.currentCt + "\",\n" +
                "  \"answerCt\": \"" + this.answerCt + "\",\n" +
                "  \"currentRate\": \"" + this.getCorrectRate() + "\",\n" +
                "  \"currentUvCt\": \"" + this.currentUvCt + "\",\n" +
                "  \"answerUvCt\": \"" + this.answerUvCt + "\",\n" +
                "  \"currentUvRate\": \"" + this.getCorrectUvRate() + "\"\n" +
                "}";
    }
}
